using System;
using Microsoft.SPOT;

namespace Gralin.NETMF.Nordic
{
    /// <summary>
    /// NRF24L01Plus Interface 
    /// 
    /// This interface is shared from the NRF24L01Plus engine and the Gadgeteer Module
    /// So upper layer classes can use both indifferently
    /// </summary>
    public interface INRF24L01Plus
    {
        /// <summary>
        /// Interface is Enabled?
        /// </summary>
        bool IsEnabled { get; }

        /// <summary>
        ///   Disables the module
        /// </summary>
        void Disable();

        /// <summary>
        ///   Enables the module
        /// </summary>
        void Enable();

        /// <summary>
        /// Configure the module basic settings. Module needs to be initiaized.
        /// </summary>
        /// <param name="address">RF address (3-5 bytes). The width of this address determins the width of all addresses used for sending/receiving.</param>
        /// <param name="channel">RF channel (0-127)</param>
        void Configure(byte[] address, byte channel);

        /// <summary>
        /// Set one of 6 available module addresses
        /// </summary>
        void SetAddress(AddressSlot slot, byte[] address);

        /// <summary>
        /// Read 1 of 6 available module addresses
        /// </summary>
        byte[] GetAddress(AddressSlot slot, int width);

        /// <summary>
        ///   Gets module basic status information
        /// </summary>
        Status GetStatus();

        /// <summary>
        ///   Reads the current rf channel value set in module
        /// </summary>
        /// <returns></returns>
        byte GetChannel();

        /// <summary>
        ///   Gets the module radio frequency [MHz]
        /// </summary>
        /// <returns>Frequency in MHz</returns>
        int GetFrequency();

        /// <summary>
        ///   Sets the rf channel value used by all data pipes
        /// </summary>
        /// <param name="channel">7 bit channel value</param>
        void SetChannel(byte channel);

        /// <summary>
        ///   Send <param name = "bytes">bytes</param> to given <param name = "address">address</param>
        ///   This is a non blocking method.
        /// </summary>
        void SendTo(byte[] address, byte[] bytes);
                
        /// <summary>
        ///   Sends <param name = "bytes">bytes</param> to given <param name = "address">address</param>
        ///   This is a blocking method that returns true if data was received by the recipient or false if timeout occured.
        /// </summary>
        bool SendTo(byte[] address, byte[] bytes, int timeout);

        /// <summary>
        ///   Occurs when data packet has been received
        /// </summary>
        event Gralin.NETMF.Nordic.NRF24L01Plus.OnDataRecievedHandler OnDataReceived;

        /// <summary>
        ///   Occurs when ack has been received for send packet
        /// </summary>
        event Gralin.NETMF.Nordic.NRF24L01Plus.EventHandler OnTransmitSuccess;

        /// <summary>
        ///   Occurs when no ack has been received for send packet
        /// </summary>
        event Gralin.NETMF.Nordic.NRF24L01Plus.EventHandler OnTransmitFailed;
    }
}
